﻿using System.IO;
using System.Text;

namespace MyOS.Models
{
    public class PCBModel
    {
        public PCBModel(string path, int number)
        {
            Name = System.IO.Path.GetFileName(path);
            Number = number;
            State = emState.ready;
            using (var stream = new FileStream(path, FileMode.Open))
            {
                Path = path;
                var buffer = new byte[1024 * 10];
                stream.Read(buffer, 0, buffer.Length);
                Program = Encoding.Default.GetString(buffer).Replace("\n", "").Replace("\r", "").Trim();
            }

            PC = 0;
            DR = 0;
        }

        public int DR { set; get; }//数据缓冲寄存器，存放x的值
        public string Name { set; get; } //进程名
        public int Number { set; get; } //进程标志符信息（id）
        public int PC { get; set; } //程序计数器
        public emState State { get; set; } //状态信息-->就绪、阻塞、执行
        public char Event { get; set; } //进程事件（阻塞原因）
        public int Timer { get; set; } //时间片
        public PCBModel Next { get; set; } //指向下一个进程控制块
        public string Program { set; get; } //存放指令
        public string Path { set; get; } //“进程”在计算机中的路径
    }
}